# Maintainer: Fabian Bornschein <fabiscafe-at-mailbox-dot-org>
# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>

pkgname=gnome-builder
pkgver=45.0
pkgrel=1
pkgdesc="An IDE for writing GNOME-based software"
url="https://wiki.gnome.org/Apps/Builder"
arch=(loong64 x86_64)
license=(GPL3)
depends=(
  autoconf-archive
  cairo
  clang
  cmark
  ctags
  d-spy
  dconf
  desktop-file-utils
  devhelp
  editorconfig-core-c
  enchant
  flatpak
  flatpak-builder
  gdk-pixbuf2
  gjs
  glib2
  gobject-introspection-runtime
  gtk4
  gtksourceview5
  hicolor-icon-theme
  icu
  json-glib
  jsonrpc-glib
  libadwaita
  libdex
  libgirepository
  libgit2-glib
  libpanel
  libpeas-2
  libportal
  libportal-gtk4
  libsoup3
  libxml2
  meson
  pango
  python
  python-lxml
  python-sphinx
  sysprof
  template-glib
  vala
  vte4
  webkitgtk-6.0
)
makedepends=(
  appstream-glib
  git
  gobject-introspection
  llvm
  mm-common
  python-lsp-server
  python-sphinx_rtd_theme
  yelp-tools
)
checkdepends=(weston)
_commit=82b055c8cc4dbcf171f8236e2a7d15cd19225fe1  # tags/45.0^0
source=("git+https://gitlab.gnome.org/GNOME/gnome-builder.git#commit=$_commit")
b2sums=('SKIP')

pkgver() {
  cd $pkgname
  git describe --tags | sed 's/[^-]*-g/r&/;s/-/+/g'
}

prepare() {
  cd $pkgname
}

build() {
  local meson_options=(
    -D help=true
  )

  arch-meson $pkgname build "${meson_options[@]}"
  meson compile -C build
}

check() (
  export XDG_RUNTIME_DIR="$PWD/runtime-dir"
  mkdir -p -m 700 "$XDG_RUNTIME_DIR"

  export WAYLAND_DISPLAY=wayland-5
  weston --backend=headless-backend.so --socket=$WAYLAND_DISPLAY --idle-time=0 &
  _w=$!

  trap "kill $_w; wait" EXIT

  dbus-run-session meson test -C build --print-errorlogs
)

package() {
  depends+=(libgit2.so)
  optdepends=(
    'bash-language-server: Shell code assistance'
    'python-lsp-server: Python code assistance'
  )
  groups=(gnome-extra)

  meson install -C build --destdir "$pkgdir"
}

# vim:set sw=2 sts=-1 et:
